package no.progark.pong;

import android.content.Context;


public class AIController extends Controller {
	private static AIController instance;

	private AIController(Context context) {
		super(context);
		
	}
	
	public static synchronized AIController getInstance(Context context) {
        if (instance == null) {
                instance = new AIController(context);
        }
        return instance;
	}
	
	public void update(int ballPos, int speed){
		if(ballPos < getPosX()){ //left of controller
			setPosX(getPosX()-speed);
//			setPosX(ballPos-CONTROLLERWIDTH/2);
		}
		else if(ballPos > getPosX()+CONTROLLERWIDTH){
			setPosX(getPosX()+speed);
//			setPosX(ballPos-CONTROLLERWIDTH/2);
		}
		//the ball will hit the controller, do nothing
	}



}
